#ifdef GL_ES
precision mediump float;
#endif

uniform sampler2D sampler2d;
varying vec2 vtex;
uniform float angle;
const float pi        = 3.1415926;

//旋转函数
vec2 rota(vec2 pos, float rad)
{
    float c = cos(rad);
    float s = sin(rad);
    mat2 m = mat2(c, -s, s, c);
    return pos*m;
}
//旋转函数
vec2 rota2(vec2 uv, float a)
{
	// [uv.x uv.y] * [cos(a),  sin(a),
	//                -sin(a), cos(a)]
	return vec2(uv.x * cos(a) - uv.y * sin(a), uv.y * cos(a) + uv.x * sin(a));
}

//初始角度设置
const float dangle = 0.;
void main (void)
{       
	//可以实现360°切割 可通过旋转坐标系控制初始角度
	vec2 uv1 = vtex - vec2(0.5, 0.5);
	vec2 uv = rota(uv1, radians(dangle));
    float a = atan(uv.y, uv.x) + pi;//顺时针
    //float a = atan(uv.y, -uv.x) + pi;//逆时针
    
	gl_FragColor = texture2D(sampler2d, vtex) * smoothstep(0.0, 1.0, angle-degrees(a));
    
}